package stmlib;

import java.io.PrintStream;

public class Exceptions extends RuntimeException {
    /** Throw this exception in a 'transact' block to retry the current transaction. */
    public static class Retry extends Exceptions {}

    /**
     * Throw this to end the current transaction immediately, without throwing an exception
     * Only works if invoked within within a transaction wrapped by the 'transact' function.
     */
    public static class Break extends Exceptions {}

    /** Wrap the Checked Exception in a RuntimeException for propagation. Internal use. */
    static class Wrap extends Exceptions {
        public final Exception exception;
        Wrap(Exception e) { this.exception = e; }
        public String toString() { return exception.toString(); }
        public void printStackTrace(PrintStream s) { exception.printStackTrace(s); }
    }

    public static class NotInTransaction extends Exceptions {}

    public static class RetryFailure extends Exceptions {}
}
